class complex {
    double a, b,p;

    complex() {
        this.a = 0;
        this.b = 0;
    }

    complex(double a) {
        this.a = a;
        this.b = 0;
    }

    complex(double a, double b) {
        this.a = a;
        this.b = b;
    }

    complex add(complex p1, complex p2) {
        complex p = new complex(p1.a + p2.a, p1.b + p2.b);

        return p;
    }

    complex minus(complex p1, complex p2) {
        complex p = new complex(p1.a - p2.a, p1.b - p2.b);
        return p;
    }

    complex multiply(complex p1, complex p2) {
        complex p = new complex(p1.a*p2.a-p1.b*p2.b,p1.a*p2.b+p1.b*p2.a);

        return p;
    }


    complex divide(complex p1, complex p2) {
        complex p = new complex((p1.a*p2.a+p1.b*p2.b)/(p2.a*p2.a+p2.b*p2.b)+(p1.b*p2.a-p1.a*p2.b)/(p2.a*p2.a+p2.b*p2.b),0);

        return p;
    }


    void print() {
        System.out.println("The complex number is :");
        if (this.b != 0)
            System.out.println(this.a + "+" + this.b + "i");
        else
            System.out.println(this.a);
    }
}
